/**
 * BoardContentsMgr.java
 * @author GorillaFunch
 * @created 2013.01.16
 */
package kr.ac.kongju.gedl.board.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import kr.ac.kongju.gedl.board.dao.BoardContentsDAO;
import kr.ac.kongju.gedl.board.service.BoardContentsService;
import kr.ac.kongju.gedl.board.vo.BulletinBoardVO;
import kr.ac.kongju.gedl.board.vo.ContentsVO;
import kr.ac.kongju.gedl.common.util.ListResultVO;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import egovframework.rte.fdl.cmmn.AbstractServiceImpl;
import egovframework.rte.fdl.property.EgovPropertyService;

@Service("reportService")
public class BoardContentsServiceImpl extends AbstractServiceImpl implements BoardContentsService{
	// Log
	private final Logger logger = LoggerFactory.getLogger(getClass());

	/** EgovPropertyService */
    @Resource(name = "propertiesService")
    protected EgovPropertyService propertiesService;
    
    @Resource(name="contentsDAO")
    private BoardContentsDAO contentsDAO;
    
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.report.service.impl.BoardContentsService#registerBoardContents(kr.ac.kongju.gedl.report.vo.BoardContentsVO)
	 */
	@Override
	public ContentsVO registerBoardContents(ContentsVO contentsVO){
		return contentsDAO.registerBoardContents(contentsVO);
	}
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.report.service.impl.BoardContentsService#retrieveBoardContents(kr.ac.kongju.gedl.report.vo.BoardContentsVO)
	 */
	@Override
	public List<ContentsVO> retrieveBoardContents(ContentsVO contentsVO){
		return contentsDAO.retrieveBoardContents(contentsVO);
	}
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.report.service.impl.BoardContentsService#updateBoardContents(kr.ac.kongju.gedl.report.vo.BoardContentsVO)
	 */
	@Override
	public ContentsVO updateBoardContents(ContentsVO contentsVO){
		return contentsDAO.updateBoardContents(contentsVO);
	}
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.report.service.impl.BoardContentsService#updateBoardContentsVisit(java.lang.String)
	 */
	@Override
	public int updateBoardContentsVisit(int contentsGroupId){
		return contentsDAO.updateBoardContentsVisit(contentsGroupId);
	}
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.report.service.impl.BoardContentsService#deleteBoardContents(java.lang.String)
	 */
	@Override
	public int deleteBoardContents(ContentsVO contentsVO){
		return contentsDAO.deleteBoardContents(contentsVO);
	}
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.report.service.impl.BoardContentsService#retrieveListCountBoardContents(com.ssc.common.service.SearchVO)
	 */
	@Override
	public int retrieveListCountBoardContents(ContentsVO searchCondition) {
		return contentsDAO.retrieveListCountBoardContents(searchCondition);	
	}
	
	/* (non-Javadoc)
	 * @see kr.ac.kongju.gedl.report.service.impl.BoardContentsService#retrieveListBoardContents(com.ssc.common.service.SearchVO)
	 */
	@Override
	public ListResultVO<ContentsVO> retrieveListBoardContents(ContentsVO searchCondition) {
		ListResultVO<ContentsVO> listResult = new ListResultVO<ContentsVO>();
		List<ContentsVO> list = new ArrayList<ContentsVO>();
		
		int count = contentsDAO.retrieveListCountBoardContents(searchCondition);
		if(count > 0){
			list = contentsDAO.retrieveListBoardContents(searchCondition);
			listResult = new ListResultVO<ContentsVO>(count, list);
		}
		logger.info("count:{} list.size:{}", count, list.size());
			
		return listResult;	
	}

	@Override
	public int getContentsGroupId() {
		// TODO Auto-generated method stub
		return contentsDAO.getContentsGroupId();
	}

	@Override
	public int getContentsSeq(int contentsGroupId) {
		// TODO Auto-generated method stub
		return contentsDAO.getContentsSeq(contentsGroupId);
	}
	
	
	
	@Override
	public BulletinBoardVO retrieveBulletinBoard(int boardId) {
		// TODO Auto-generated method stub
		BulletinBoardVO bulletinBoardVO = new BulletinBoardVO();
		bulletinBoardVO.setBoardId(boardId);
		return contentsDAO.retrieveBulletinBoard(bulletinBoardVO);
	}
	
	
	public void updateViewCnt(ContentsVO searchCondition) {
		contentsDAO.updateViewCnt(searchCondition);
	}
	

	
}
